{extend name="AdminController/index" /}
{block name="main"}
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<div class="content-page">
    <div class="content">
        <h1>{$title}</h1>
        <form name='searchform' action="{:url('search')}" method='get'>
         <input name='keyword' type='text' class="form-control" />
         <input type='submit' name='search' class='btn btn-success' />
         </form>
    </div>
     <div>
        <table class="table table-striped">
    <thead>
        <tr>
            <th>评论ID</th>
            <th>用户Name</th>
            <th>电影Name</th>
            <th>类型</th>
            <th>评分</th>
            <th>评论</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        {volist name="data" id="vo"}
        <tr>
            <td>{$vo.id}</td>
            <td>{$vo.name} </td>
            <td>{$vo.mname}</td>
            <td>{$vo.type}</td>
            <td>{$vo.score}</td>
            <td>{$vo.comment}</td>
           
           
            <td>

               <button class="btn btn-danger btn del-btn" data-id="{$vo.id}">删除</button>
               
            </td>
        </tr>
        {/volist}
        
        
    </tbody>
</table>
    </div>
{$page}
</div>

{js href="/static/admin/js/toastr.min.js"}
{js href="/static/admin/js/jquery.min.js"}
{js href="/static/admin/js/bootstrap.min.js"}



<script>
        $(function(){

        // 触发删除内容
        $('.del-btn').click(function (){
            var ac_id = $(this).attr('data-id');
            // console.log('删除操作,ID:', ac_id);
            var obj = $(this).parents('tr');
            if (confirm('你确定要[删除]吗?!')) {
                var obj = $(this).parents('tr');
                delAjax(ac_id, obj); // 执行AJAX删除
            }
        });
        // AJAX删除
        function delAjax(id,obj){
            // console.log(obj);
            $.ajax({
            type: 'post',
            url: 'delete' ,
            data: {
                id:id
            },
            dataType: 'json',
            success: function (data) {
                console.log(data);
                if (data.status) {
                    // 将该条目删除掉
                    obj.remove();
                } else {
                }
            },
            error: function () {
                alert('AJAX操作失败');
            }
        });
        }
        })
    </script>
{/block}